<?php

namespace App\Repositories\Stock;

use App\Enum;
use App\Models\Stock\ProductStock;
use App\Repositories\BaseRepository;

class ProductStockRepository extends BaseRepository
{

    public function __construct(ProductStock $model)
    {
        parent::__construct($model);
    }


    public function getNum($productId,$storageId)
    {
        return $this->model->where('product_id',$productId)->where('storage_id',$storageId)->value('num');
    }


    public function getListWithProduct($columns = ['*'],$where=[],$page=1,$limit=15,$sort='created_at',$order='desc')
    {

        return $this->model->with('product')->with('storage')->where($where)
            ->orderBy($sort, $order)
            ->paginate($limit, $columns, 'page', $page);

    }


    public function getTotalCostPrice()
    {
        return $this->model->sum('total_cost_price');
    }

}